package com.thor.palmmall.rest.order.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.order.AProductLine;
import com.thor.palmmall.spi.order.SProductLine;

public class SProductLineConverter implements Converter<List<AProductLine>,List<SProductLine>>{
	public static SProductLineConverter getInstance() {
		if (instance == null)
			instance = new SProductLineConverter();
		return instance;
	}

	private static SProductLineConverter instance;

	@Override
	public List<SProductLine> convert(List<AProductLine> sourceList) {
		if(sourceList == null || sourceList.size()==0){
			return null;
		}
		List<SProductLine> list = new ArrayList<SProductLine>();
		for (AProductLine source : sourceList) {
			SProductLine target = new SProductLine();
			target.setUuid(source.getUuid());
			target.setPdtUuid(source.getPdtUuid());
			target.setCode(source.getCode());
			target.setName(source.getName());
			target.setSpecification(source.getSpecification());
			target.setModel(source.getModel());
			target.setQty(source.getQty());
			target.setPrice(source.getPrice());
			target.setOriginalPrice(source.getOriginalPrice());
			target.setStdTotal(source.getStdTotal());
			target.setRemark(source.getRemark());
			target.setCategory(UCN.newInstance(source.getCategory()));
			list.add(target);
		}
		return list;
	}
}

